package top.zhangjianyong.tools.remind.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.zhangjianyong.tools.entity.RemindItem;
import top.zhangjianyong.tools.utils.HolidayUtil;
import top.zhangjianyong.tools.utils.RemindUtil;

import java.time.LocalDate;

/**
 * @author ： zhangjianyong
 * @date ： 2022/10/9 4:38 PM
 */
@Component
public class StockRemindStrategy implements RemindStrategy {


    @Autowired
    private HolidayUtil holidayUtil;
    @Autowired
    private RemindUtil remindUtil;

    @Override
    public String type() {
        return "股市";
    }

    @Override
    public void remind(RemindItem remindItem) throws Exception {

        if (holidayUtil.isStock(LocalDate.now())) {
            remindUtil.sendEmail(remindItem);
        } else {
            remindUtil.sendEmailAndClose(remindItem);
        }
    }

    @Override
    public boolean reset() {
        return true;
    }
}
